/*

Author   : chaos

FileName : access_protected.cpp

Date     : 14/08/17 01:15:18

*/
#include <iostream>
using namespace std;
class Base
{
    private:
        int pri_att;
        void pri_show()
        {
            cout << "Base::pri_show() is called !" << endl;
        }
    protected:
        int pro_att;
        void pro_show()
        {
            cout << "Base::pro_show() is called !" << endl;
        }
    public:
        Base():pri_att(1),pro_att(2),pub_att(3){}
        int pub_att;
        void pub_show()
        {
            cout << "Base::pub_show() is called !" << endl;
        }

};

class Derived : protected Base
{
    public:
        void call_fun();
        void show();
        void access_protected(Base & aBase);
};

void Derived::call_fun()
{
    cout <<"Derived::call_fun is called !" << endl;
    pub_show();
    pro_show();
    //pri_show();
}

void Derived::show()
{
    cout << endl;
    cout <<"Derived::show() is called !" << endl;
    cout << "Base::pub_att = " << pub_att << endl;
    cout << "Base::pro_att = " << pro_att << endl;
    //cout << "Base::pri_att = " << pri_att << endl;
}

void Derived::access_protected(Base & aBase)
{
    cout <<"Derived::access_protected() is called !" << endl;
    //cout << aBase.pro_att << endl;

    //aBase.pro_show();
}
int main(int argc ,char *argv[])
{
    Derived A_Derived;
    Base A_Base;

    A_Derived.call_fun();

    A_Derived.show();

    A_Derived.access_protected(A_Base);

    return 0;
}
